<?php
require_once('../exceptions/DatabaseException.php');

class JoinTable
{
	protected $name;
	protected $conditions;
	
	public function __construct($_name,$_conditions)
	{
		$this->name=$_name;
		foreach($conditions as $condition)
			$condition=Database.escape($condition);
		$this->conditions=$_conditions;
	}
	
	public function setName($_name)
	{
		$this->name=$_name;
	}
	
	public function getName()
	{
		return $this->name;
	}
	
	public function setConditions($_conditions)
	{
		$this->conditions=$_conditions;
	}
	
	public function getConditions()
	{
		return $this->conditions;
	}
	
	public function getContent()
	{
		if(strlen($this->conditions)<=0) {
			throw new DatabaseException(DatabaseException::ERROR_NO_CONDITION_EXISTS_IN_JOIN,DatabaseException::NO_NO_CONDITION_EXISTS_IN_JOIN);
		}
		return $this->name." ON (".$this->conditions.")";
	}
}
?>